module.exports = function (gulp, $, config) {
  // Compile Sass into CSS
  // In production, the CSS is compressed
  gulp.task('sass', function(done) {
    var minifycss = $.if(config.isProduction, $.cleanCss({keepSpecialComments: 0}));

    return gulp.src(config.sass.src)
      .pipe($.sourcemaps.init())
      .pipe($.sass({
        includePaths: config.sass.path,
        errLogToConsole: true
      })
        .on('error', $.sass.logError))
      .pipe($.autoprefixer({
        browsers: config.sass.compatibility
      }))
      // .pipe(uncss)
      .pipe(minifycss)
      .pipe($.if(!config.isProduction, $.sourcemaps.write()))
      .pipe(gulp.dest(config.sass.dest))
      .pipe($.browser.stream());
  });
}